% RANDOMLY SELECT THE VARIETIES THAT WILL RECEIVE AN INNOVATION DRAW USING
% THE CONDITIONAL INNOVATION PROCEDURE:
        probability_draws_incumbents.US = rand(n_varieties,1);
        potentialincumbentsteals.US = probability_draws_incumbents.US < lambda.US;
        probability_draws_entrants.US = rand(n_varieties,1);
        potentialentrants.US = probability_draws_entrants.US < eta.US & ~potentialincumbentsteals.US;
        probability_draws_incumbents.OECD = rand(n_varieties,1);
        potentialincumbentsteals.OECD = probability_draws_incumbents.OECD < lambda.OECD & ~potentialincumbentsteals.US & ~potentialentrants.US;
        probability_draws_entrants.OECD = rand(n_varieties,1);
        potentialentrants.OECD = probability_draws_entrants.OECD < eta.OECD & ~potentialincumbentsteals.US & ~potentialentrants.US & ~potentialincumbentsteals.OECD;
               
for cc=1:length(place)
% CONDUCT A PARETO DRAW FOR EACH POTENTIALLY STOLEN VARIETY
if year > 2
        inverse_relative_qual.(place{cc}) = qualities_vec.(place{3-cc})./qualities_vec.(place{cc});
        disembodied_draw_on_foreign.(place{cc}) = logical(inverse_relative_qual.(place{cc})>=prctile(inverse_relative_qual.(place{cc}),100-100*z.(place{cc})));
        qualities_vec_for_draws.(place{cc}) = qualities_vec.(place{cc}); 
        qualities_vec_for_draws.(place{cc})(disembodied_draw_on_foreign.(place{cc})) = qualities_vec.(place{3-cc})(disembodied_draw_on_foreign.(place{cc}));
        maybe_stolen.(place{cc}) = potentialentrants.(place{cc}) | potentialincumbentsteals.(place{cc});
        num_draws.(place{cc}) = sum(maybe_stolen.(place{cc}));        
        productivitydraws.(place{cc}) = Pareto_draw(beta.(place{cc}),theta.(place{cc}), ... 
                qualities_vec_for_draws.(place{cc})(maybe_stolen.(place{cc})),num_draws.(place{cc}));
else
        qualities_vec_for_draws.(place{cc}) = qualities_vec_consumed.(place{cc});
        maybe_stolen.(place{cc}) = potentialentrants.(place{cc}) | potentialincumbentsteals.(place{cc});
        num_draws.(place{cc}) = sum(maybe_stolen.(place{cc}));        
        productivitydraws.(place{cc}) = Pareto_draw(beta.(place{cc}),theta.(place{cc}), ... 
                qualities_vec_for_draws.(place{cc})(maybe_stolen.(place{cc})),num_draws.(place{cc}));
end    
        
        tmp_qual.(place{cc}) = -1*ones(size(qualities_vec.(place{cc})));
        tmp_qual.(place{cc})(maybe_stolen.(place{cc})) = productivitydraws.(place{cc});
        was_stolen.(place{cc}) = tmp_qual.(place{cc})>= qualities_vec.(place{cc});      
        incumbentsteals.(place{cc}) = potentialincumbentsteals.(place{cc}) & was_stolen.(place{cc});
        entrants.(place{cc}) = potentialentrants.(place{cc}) & was_stolen.(place{cc});
           
 % ALLOCATE STOLEN VARIETIES TO EXISTING INCUMBENTS WITHOUT REPLACEMENT
 % (first command is the real one - the other two are just for bizarre cases where incumbent steals are more than existing varieties or no varieties are owned by one country)
 if sum(incumbentsteals.(place{cc})) < length(varown_vec.(place{cc}).(year_index)(~isnan(varown_vec.(place{cc}).(year_index)))) && ~isempty(varown_vec.(place{cc}).(year_index)(~isnan(varown_vec.(place{cc}).(year_index))))
        who_stole.(place{cc}) = datasample(varown_vec.(place{cc}).(year_index)(~isnan(varown_vec.(place{cc}).(year_index)))...
            ,sum(incumbentsteals.(place{cc})),'Replace',false);
 elseif sum(incumbentsteals.(place{cc})) >= length(varown_vec.(place{cc}).(year_index)(~isnan(varown_vec.(place{cc}).(year_index)))) && ~isempty(varown_vec.(place{cc}).(year_index)(~isnan(varown_vec.(place{cc}).(year_index))))
        who_stole.(place{cc}) = datasample(varown_vec.(place{cc}).(year_index)(~isnan(varown_vec.(place{cc}).(year_index)))...
            ,sum(incumbentsteals.(place{cc})),'Replace',true);
 elseif isempty(varown_vec.(place{cc}).(year_index)(~isnan(varown_vec.(place{cc}).(year_index))))
        who_stole.(place{cc}) = datasample(varown_vec.(place{cc}).(year_index)...
            ,sum(incumbentsteals.(place{cc})),'Replace',false);
 end
 
 % UPDATE VARIETY OWNERSHIP TO STEALING INCUMBENTS  
 % (ENTRANT STEALS ARE DONE AFTER INTERNATIONAL EQUILIBRIUM DETERMINES
 % WHETHER A VARIETY IS PRODUCED BY US OR CANADA)
        varown_vec.(place{cc}).(year_index)(incumbentsteals.(place{cc})) = who_stole.(place{cc});
        
 % UPDATE VARIETY QUALITIES OF LEADING PRODUCER AND LEADING DOMESTIC
 % COMPETITOR
        domestic_competitor_qual_vec.(place{cc})(was_stolen.(place{cc})) = qualities_vec.(place{cc})(was_stolen.(place{cc}));
        qualities_vec.(place{cc})(was_stolen.(place{cc})) = tmp_qual.(place{cc})(was_stolen.(place{cc}));
        
end
    
    